/**
 * 
 */
package hutil;

/**
 * @author liutao
 * 
 */
public class MyTime {
	public int year = 0;
	public int mouth = 0;
	public int date = 0;
	public int week = 0;
	public int hour = 0;
	public int minutes = 0;
	public int second = 0;

	/**
	 * @param year
	 * @param mouth
	 * @param date
	 * @param week
	 * @param hour
	 * @param minutes
	 * @param second
	 */
	public MyTime(int year, int mouth, int date, int week, int hour,
			int minutes, int second) {
		super();
		this.year = year;
		this.mouth = mouth;
		this.date = date;
		this.week = week;
		this.hour = hour;
		this.minutes = minutes;
		this.second = second;
	}

	/**
	 * example "Mon Jan 00 00:00:00 CST 1000"
	 */
	public MyTime(String time) {
		super();
		String[] ts = time.split(" ");
		// year
		this.year = Integer.parseInt(ts[5]);
		// mouth
		if (ts[1] == "Jan")
			this.mouth = 1;
		else if (ts[1] == "Feb")
			this.mouth = 2;
		else if (ts[1] == "Mar")
			this.mouth = 3;
		else if (ts[1] == "Apr")
			this.mouth = 4;
		else if (ts[1] == "May")
			this.mouth = 5;
		else if (ts[1] == "Jun")
			this.mouth = 6;
		else if (ts[1] == "Jul")
			this.mouth = 7;
		else if (ts[1] == "Aug")
			this.mouth = 8;
		else if (ts[1] == "Sep")
			this.mouth = 9;
		else if (ts[1] == "Oct")
			this.mouth = 10;
		else if (ts[1] == "Nov")
			this.mouth = 11;
		else if (ts[1] == "Dec")
			this.mouth = 12;
		// week
		if (ts[0] == "Mon")
			this.week = 1;
		else if (ts[0] == "Tues")
			this.week = 2;
		else if (ts[0] == "Wed")
			this.week = 3;
		else if (ts[0] == "Thur")
			this.week = 4;
		else if (ts[0] == "Fri")
			this.week = 5;
		else if (ts[0] == "Sat")
			this.week = 6;
		else if (ts[0] == "Sun")
			this.week = 7;
		// day
		this.date = Integer.parseInt(ts[2]);

		//parse time
		String[] hms = ts[3].split(":");
		// hout
		this.hour = Integer.parseInt(hms[0]);
		// minutes
		this.minutes = Integer.parseInt(hms[1]);
		// second
		this.second = Integer.parseInt(hms[2]);
	}

	public int GetTimeThreshold() {
		int thr = 0;
		thr += (this.year - 1000) * 365 * 24 * 60 * 60 + (this.mouth - 1) * 30
				* 24 * 60 * 60 + (this.date - 1) * 24 * 60 * 60
				+ (this.hour - 0) * 60 * 60 + (this.minutes - 0) * 60
				+ (this.second - 0);
		return thr;
	}

	/**
	 * 
	 */
	public MyTime() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//MyTime mt = new MyTime("Mon Jan 00 00:00:00 CST 1000");
		MyTime mt2 = new MyTime("Mon Feb 11 03:01:01 CST 1300");
		System.out.print(mt2.GetTimeThreshold());
	}

}
